package b1.scenes.fight
{
	import b1.conifg.Config;
	import b1.conifg.ObstacleConfig;
	import b1.controls.basic.BasicMessage;
	import b1.net.*;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	public class Stone extends FightObject
	{
		private var stoneImg:Sprite;
		private var stoneConfig:ObstacleConfig;
		private const stoneWidth:int = 100;
		private var stoneTip:BasicMessage;
		
		public function Stone(index:int)
		{
			super(true);
			var StoneImg:Class = ResourceHelper.getInstance().getClassByName("Obstacle" + index);
			stoneImg = new StoneImg();
			stoneImg.height = stoneWidth * stoneImg.height / stoneImg.width;
			stoneImg.width = stoneWidth;
			addChild(stoneImg);
			stoneConfig = Config.obstacleConfigs[index];
			hitPoints = stoneConfig.hitPoints;
			
			this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
		}
		
		//显示“石头”文本
		public function onMouseOver(event:MouseEvent):void
		{
			var tipString:String = stoneConfig.name;
			stoneTip = new BasicMessage(tipString.length * 20, 25, tipString);
			stoneTip.x = this.x  + (this.width - stoneTip.width) / 2;
			stoneTip.y = this.y - this.stoneTip.height - 2;
			this.parent.addChild(stoneTip);
		}
		
		//去掉“石头”文本
		public function onMouseOut(event:MouseEvent):void
		{
			if (null !=  this.stoneTip && null !=  this.stoneTip.parent)
        	{
        		this.parent.removeChild(stoneTip);
        	}
		}
		
	}
}




		